#!/bin/sh

source "$1/Contents/Resources/common"

rm -Rvf "$dst_demon"

cp -Rvf "$src_demon" "$dst_demon"
chmod -R u=rwx,go=rx  "$dst_demon"


rm -vf "$dst_autoruntool"
cp -vf "$src_autoruntool" "$dst_autoruntool"
chmod  u=rwx,go=rx "$dst_autoruntool"


echo "Copy profile to modemlist & change file permission ----"

rm -vf "$dst_profile"
cp  -vf "$src_profile" "$dst_profile"
chmod a=rw "$dst_profile"




allusers=
cd "$home_root"
allusers=$(echo *)


 
echo "Iterator all user name -----"
for oneuser in $allusers;
do
filepath="$home_root/$oneuser/$login_file"

	if [ -e "$filepath" ]; then
	ls -l  "$filepath"

	echo "Temporary change the file permission -----"
	chmod a=rw "$filepath"
	ls -l "$filepath"

	cd "$dst_root"
 	./autoruntool "$filepath" "$dst_demon"
	

	echo "Restore the file permission -----"

	chmod u=rw,go= "$filepath"
	ls -l  "$filepath"
	fi
	
done
